Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exports to package.json to satisfy nodejs --experimental-module u… #207

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jamie-pate
Copy link

…sers

Fixes #206
This ensures that consumers using --experimental-modules with node 12+
will import the esm version of this package.

This package's export MUST have .mjs file extension... (because
otherwise the entire package must be specified as type: module)
This package's export MUST use exports field in the package.json
see https://nodejs.org/api/packages.html#conditional-exports

Not sure how to test this with a bunch of different project styles..
webpack and other loaders should be fine with importing from the
module field with a .mjs file extension?

@jamie-pate
Copy link
Author

Looks like we can create a package.json in the es5m dir that only has {"type": "module"} to satisfy NodeJS

…sers

Fixes insidewhy#206
This ensures that consumers using --experimental-modules with node 12+
will import the esm version of this package.

This package's export must a package.json with "type": "json" (or module
files must have .mjs extension)...
This package's export must also use exports field in the package.json
because node doesn't support the "module" field as an alternative to
"main".
	see https://nodejs.org/api/packages.html#conditional-exports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add exports field to support newer versions of nodejs
1 participant